﻿using System;
using System.Collections.Generic;

namespace Core.Logger
{
    /// <summary>
    /// The class is a wrapper for <see cref="LoggerMemory"/> singleton.
    /// It shortens the call LoggerMemory object.
    /// </summary>
    public static class LoggerInstance
    {
        private static readonly ILogger _logger;
        public static event EventHandler<AfterAppendEventArgs> AfterAppend;
        public static event EventHandler AfterClear;

        static LoggerInstance()
        {
            // decide which logger to use (if adding later)
            _logger = LoggerMemory.Instance;
            _logger.AfterAppend += logger_AfterAppend;
            _logger.AfterClear += logger_AfterClear;
        }

        private static void logger_AfterClear(object sender, EventArgs e)
        {
            var temp = AfterClear;
            if (temp != null)
            {
                temp(sender, e);
            }
        }

        private static void logger_AfterAppend(object sender, AfterAppendEventArgs e)
        {
            var temp = AfterAppend;
            if (temp != null)
            {
                temp(sender, e);
            }
        }
       
        public static void Append(string message, params object[] args)
        {
            _logger.Append(message, args);
        }
        public static void Append(LogStatus status, string message, params object[] args)
        {
            _logger.Append(status, message, args);
        }
        public static void Append(LogItem logItem)
        {
            _logger.Append(logItem);
        }

        public static void Clear()
        {
            _logger.Clear();
        }
        public static List<LogItem> GetLogs()
        {
            return _logger.GetLogs();
        }
        public static List<string> GetErrors()
        {
            return _logger.GetErrors();
        }
        public static List<string> GetWarnings()
        {
            return _logger.GetWarnings();
        }
    }
}